package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.reggie.domain.User;
import com.itheima.reggie.mapper.UserMapper;
import com.itheima.reggie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

//用户
@Service
@Transactional
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userMapper;
	
	@Override
	public void save(User user) {
		userMapper.insert(user);
	
	}
	
	@Override
	public User findByPhone(String phone) {
		
		LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
		
		wrapper.eq(User::getPhone, phone);
		
		return userMapper.selectOne(wrapper);
	}
}
